home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{9D23596C-B861-11D2-A020-00C04F72D7D2}#1.0#0"; "dBase64.dll"
- Begin VB.Form Form1
- Caption = "DameWare Base64 Encoder/Decoder Sample"
- ClientHeight = 3960
- ClientLeft = 60
- ClientTop = 348
- ClientWidth = 5988
- LinkTopic = "Form1"
- ScaleHeight = 3960
- ScaleWidth = 5988
- StartUpPosition = 2 'CenterScreen
- Begin VB.CommandButton Command3
- Caption = "Binary File"
- Height = 372
- Left = 4800
- TabIndex = 9
- Top = 1920
- Width = 1092
- End
- Begin VB.TextBox Text1
- Height = 855
- Left = 0
- MultiLine = -1 'True
- TabIndex = 0
- Text = "dBase64.frx":0000
- Top = 480
- Width = 4575
- End
- Begin VB.CommandButton Command1
- Caption = "Encode"
- Default = -1 'True
- Height = 375
- Left = 4800
- TabIndex = 1
- Top = 720
- Width = 1095
- End
- Begin VB.TextBox Text2
- Height = 855
- Left = 0
- MultiLine = -1 'True
- TabIndex = 3
- Top = 1680
- Width = 4575
- End
- Begin VB.TextBox Text3
- Height = 855
- Left = 0
- MultiLine = -1 'True
- TabIndex = 4
- Top = 3000
- Width = 4575
- End
- Begin VB.CommandButton Command2
- Caption = "Decode"
- Height = 375
- Left = 4800
- TabIndex = 2
- Top = 1320
- Width = 1095
- End
- Begin DBASE64LibCtl.Base64Ctl Base64Ctl1
- Height = 480
- Left = 5160
- TabIndex = 8
- Top = 120
- Width = 480
- _cx = 4588367
- _cy = 4588367
- EncodedString = ""
- DecodedString = ""
- End
- Begin VB.Label Label1
- Caption = "Text to Encode"
- Height = 255
- Left = 0
- TabIndex = 7
- Top = 240
- Width = 1935
- End
- Begin VB.Label Label2
- Caption = "Encoded Result "
- Height = 255
- Left = 0
- TabIndex = 6
- Top = 1440
- Width = 1935
- End
- Begin VB.Label Label3
- Caption = "Decoded Result "
- Height = 255
- Left = 0
- TabIndex = 5
- Top = 2760
- Width = 1935
- End
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Private Sub Command1_Click()
- Text2.Text = ""
- Text2.Refresh
- Base64Ctl1.DecodedString = Text1.Text
- Base64Ctl1.Encode
- Text2.Text = Base64Ctl1.EncodedString
- End Sub
- Private Sub Command2_Click()
- Text3.Text = ""
- Text3.Refresh
- Base64Ctl1.EncodedString = Text2.Text
- Base64Ctl1.Decode
- Text3.Text = Base64Ctl1.DecodedString
- End Sub
- Private Sub Command3_Click()
- On Error GoTo errorlogic
- Dim Msg As String
- Dim MyBinFile, MyBinFileEncoded, MyBinFileDecoded As String
- MyBinFile = InputBox("Enter binary file to encode/decode: ", , "c:\Program Files\DameWare\dBase64\testbin.doc")
- If MyBinFile <> "" Then ' user pressed Cancel...
- MyBinFile = Dir(MyBinFile)
- If MyBinFile <> "" Then
- TheDecimalPosition = InStr(1, MyBinFile, ".")
- TheFileExtent = Mid(MyBinFile, TheDecimalPosition + 1, 3)
- MyBinFileEncoded = Mid(MyBinFile, 1, TheDecimalPosition - 1) & "e.txt"
- MyBinFileDecoded = Mid(MyBinFile, 1, TheDecimalPosition - 1) & "d." & _
- TheFileExtent
-
- Open MyBinFile For Binary As #1
- ' Set Msg equal to # of chars as the file
- Msg = String(FileLen(MyBinFile), " ")
- ' Read the file into Msg
- Get #1, , Msg
-
- ' Encode the string
- Base64Ctl1.DecodedString = Msg
- Base64Ctl1.Encode
- Msg = Base64Ctl1.EncodedString
-
- Close #1
-
- Open MyBinFileEncoded For Binary As #1
- Put #1, , Msg ' write out encoded "e" file.
- Close #1
-
- ' Decode the string
- Base64Ctl1.EncodedString = Msg
- Base64Ctl1.Decode
-
- Open MyBinFileDecoded For Binary As #1
- Put #1, , Base64Ctl1.DecodedString ' write out decoded "d" file.
- Close #1
-
- MsgBox "The resulting encoded binary file is: " & MyBinFileEncoded & Chr(13) & Chr(10) & CrLf & _
- "The resulting decoded binary file is: " & MyBinFileDecoded
- Else
- MsgBox ("File not found")
- End If
- End If
- errorlogic:
- If Err.Number <> 0 Then
- Msg = "Error # " & Str(Err.Number) & " was generated by " _
- & Err.Source & Chr(13) & Err.Description
- MsgBox Msg, , "Error", Err.HelpFile, Err.HelpContext
- End If
- End Sub
- Private Sub Form_Load()
- Text1.Text = "This is a sample string used to demonstrate the Base64 Encoding and Decoding."
- End Sub
-